package cn.tedu.charging.device.controller;

import cn.tedu.common.pojo.param.GunStatusUpdateParam;
import cn.tedu.common.pojo.vo.StationInfoVO;
import cn.tedu.charging.device.service.DeviceService;
import cn.tedu.common.pojo.JsonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RequestMapping("device")
@RestController
@Api(tags = "设备接口")
public class DeviceController {

    @Autowired
    private DeviceService deviceService;

    /**
     * 修改枪的状态为使用中
     */
    @ApiOperation("更新枪状态")
    @PostMapping("/station/pile/gun/status/update")
    public JsonResult<Boolean> updateGunStatus(@RequestBody GunStatusUpdateParam param){
        log.debug("更新枪状态:{}",param);
        Boolean success = deviceService.updateGunStatus(param);
        JsonResult result = JsonResult.ok(success);
        log.debug("更新枪状态:{},出参:{}",param,result);
        return result;
    }

    /**
     *  获取场站信息
     */
    @ApiOperation("获取场站信息")
    @PostMapping("/station/info/{gunId}")
    public JsonResult<StationInfoVO> getStationInfo(@PathVariable("gunId") Integer gunId){
        log.debug("获取场站信息入参:{}",gunId);
        StationInfoVO stationInfoVO = deviceService.getStationInfo(gunId);
        JsonResult result = JsonResult.ok(stationInfoVO);
        log.debug("获取场站信息入参:{},出参:{}",gunId,result);
        return result;
    }






}
